<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Linux 系统调试利器：strace 与 lsof 深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .code-block {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 12px;
            padding: 1.5rem;
            margin: 1rem 0;
            position: relative;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        }
        
        .code-block::before {
            content: 'BASH';
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 600;
        }
        
        .section-title {
            position: relative;
            display: inline-block;
            margin-bottom: 2rem;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
            margin-bottom: 1rem;
            box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
        }
        
        .list-item {
            position: relative;
            padding-left: 2rem;
            margin-bottom: 1rem;
        }
        
        .list-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0.5rem;
            width: 8px;
            height: 8px;
            background: #667eea;
            border-radius: 50%;
        }
        
        .highlight-text {
            background: linear-gradient(120deg, #f093fb 0%, #f5576c 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 700;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-pulse">
                <i class="fas fa-terminal mr-4"></i>Linux 系统调试利器
            </h1>
            <p class="text-2xl md:text-3xl mb-8 opacity-90">strace 与 lsof 深度解析</p>
            <p class="text-lg md:text-xl max-w-3xl mx-auto opacity-80">
                掌握这两个强大的命令行工具，让系统故障排查变得轻而易举。从系统调用追踪到文件资源监控，助你成为 Linux 调试专家。
            </p>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-7xl mx-auto px-6 py-12">
        <!-- Introduction Card -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <div class="prose prose-lg max-w-none">
                <p class="text-gray-700 leading-relaxed text-lg">
                    <span class="text-2xl font-serif text-purple-600 float-left mr-2 leading-none">在</span>Linux 系统管理和开发中，<code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">strace</code> 和 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">lsof</code> 是两个不可或缺的故障排查工具。它们分别专注于系统调用跟踪和文件资源监控，能够帮助我们深入理解程序行为，快速定位和解决各种系统问题。
                </p>
            </div>
        </div>

        <!-- Tool Comparison Visualization -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">工具对比概览</h2>
            <div class="mermaid">
                graph LR
                    A[Linux 调试工具] --> B[strace]
                    A --> C[lsof]
                    B --> D[系统调用追踪]
                    B --> E[信号监控]
                    B --> F[性能分析]
                    C --> G[文件监控]
                    C --> H[网络连接]
                    C --> I[资源占用]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                    style B fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#f5576c,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- strace Section -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8 mb-12">
            <div class="lg:col-span-3">
                <h2 class="section-title text-4xl font-bold text-gray-800 mb-8">
                    <i class="fas fa-microscope mr-3 text-purple-600"></i>strace 系统调用追踪大师
                </h2>
            </div>
            
            <!-- Basic Usage -->
            <div class="content-card rounded-2xl p-6">
                <div class="feature-icon">
                    <i class="fas fa-play-circle"></i>
                </div>
                <h3 class="text-2xl font-bold mb-4 text-gray-800">基础用法</h3>
                
                <div class="space-y-4">
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">跟踪运行中的进程</p>
                        <div class="code-block">strace -p &lt;pid&gt;</div>
                    </div>
                    
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">启动并跟踪新进程</p>
                        <div class="code-block">strace ls -l</div>
                    </div>
                    
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">保存输出到文件</p>
                        <div class="code-block">strace -o output.txt &lt;command&gt;</div>
                    </div>
                </div>
            </div>
            
            <!-- Advanced Usage -->
            <div class="content-card rounded-2xl p-6">
                <div class="feature-icon">
                    <i class="fas fa-cogs"></i>
                </div>
                <h3 class="text-2xl font-bold mb-4 text-gray-800">高级技巧</h3>
                
                <div class="space-y-4">
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">过滤特定系统调用</p>
                        <div class="code-block">strace -e trace=open,read,write &lt;command&gt;</div>
                    </div>
                    
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">显示调用执行时间</p>
                        <div class="code-block">strace -T &lt;command&gt;</div>
                    </div>
                    
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">监控特定信号</p>
                        <div class="code-block">strace -e signal=term &lt;command&gt;</div>
                    </div>
                </div>
            </div>
            
            <!-- Application Scenarios -->
            <div class="content-card rounded-2xl p-6">
                <div class="feature-icon">
                    <i class="fas fa-lightbulb"></i>
                </div>
                <h3 class="text-2xl font-bold mb-4 text-gray-800">应用场景</h3>
                
                <div class="space-y-3">
                    <div class="list-item">
                        <p class="text-gray-700"><span class="font-semibold">诊断程序挂起</span>：识别进程等待的系统调用或资源</p>
                    </div>
                    <div class="list-item">
                        <p class="text-gray-700"><span class="font-semibold">性能瓶颈分析</span>：找出耗时的系统调用</p>
                    </div>
                    <div class="list-item">
                        <p class="text-gray-700"><span class="font-semibold">文件访问排查</span>：跟踪文件操作行为</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- lsof Section -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8 mb-12">
            <div class="lg:col-span-3">
                <h2 class="section-title text-4xl font-bold text-gray-800 mb-8">
                    <i class="fas fa-folder-open mr-3 text-pink-600"></i>lsof 文件资源监控专家
                </h2>
            </div>
            
            <!-- Basic Usage -->
            <div class="content-card rounded-2xl p-6">
                <div class="feature-icon" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
                    <i class="fas fa-list"></i>
                </div>
                <h3 class="text-2xl font-bold mb-4 text-gray-800">基础命令</h3>
                
                <div class="space-y-4">
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">列出所有打开的文件</p>
                        <div class="code-block">lsof</div>
                    </div>
                    
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">查看进程打开的文件</p>
                        <div class="code-block">lsof -p 1234</div>
                    </div>
                    
                    <div>
                        <p class="font-semibold text-gray-700 mb-2">查看文件被谁打开</p>
                        <div class="code-block">lsof /var/log/syslog</div>
                    </div>
                </div>
            </div>
            
            <!-- Network Features -->
            <div class="content-card rounded-2xl p-6">
                <div class="feature-icon" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
                    <i class="fas fa-network-wired"></i>
                </div>
                <h3 class="text-2xl font-bold mb-4 text-gray-800">网络功能</h3>
                
                <div class